package dniefirma;


import org.gruposp2p.dnie.model.DNIeAuthority;
import org.gruposp2p.dnie.model.DNIeUser;
import org.gruposp2p.dnie.service.DNIeUserDAO;
import org.gruposp2p.dnie.utils.DateUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author jj
 */
public class CreateUser {

    private static DNIeUserDAO userDao;

    public static void main (String[] args) {
        ApplicationContext appCtxt = new ClassPathXmlApplicationContext("applicationContext.xml");
        userDao = (DNIeUserDAO)appCtxt.getBean("userDao");
        DNIeUser user = new DNIeUser ();
        user.setEnabled(Boolean.TRUE);
        user.setName("JJ");
        user.setNif("55555");
        user.setAuthority(DNIeAuthority.ROLE_USER);
        user.setDateAdded(DateUtils.getTodayDate());
        userDao.save(user);
        System.out.println("user.getId(): " + user.getId());
    }

}
